home *** CD-ROM | disk | FTP | other *** search
- /*
- ** GetVol
- ** An XFNC that returns a list of the currently mounted volumes.
- ** Note the absence of robust error checking.
- ** GetVol returns a return delimited list of the volumes currently mounted...
- **
- ** Neil Day
- ** Electronic Media Group
- ** © Apple Computer, Inc. 1990
- **
- ** Use the following MPW commands to compile and link this...
- **
- ** c -b GetVol.c
- ** link -w -rt XFCN=22502 ∂
- ** -m ENTRYPOINT∂
- ** -sg GetVol GetVol.c.o∂
- ** "{libraries}HyperXLib.o" ∂
- ** "{libraries}Interface.o" ∂
- ** "{Clibraries}"StdCLib.o ∂
- ** "{Clibraries}"CInterface.o ∂
- ** "{Clibraries}"CRuntime.o ∂
- ** -o "vessel"
- */
-
- #include <types.h> /* Compiler Interfaces to */
- #include <resources.h> /* various managers and */
- #include <files.h> /* resources ... */
- #include <Packages.h>
- #include <String.h>
- #include <OSEvents.h>
- #include <Memory.h>
- #include <Events.h>
- #include <Errors.h>
- #include <Desk.h>
- #include <Strings.h>
- #include <Memory.h>
- #include <OSUtils.h>
- #include <HyperXCmd.h>
-
- void SCopy (unsigned short pos,char *dest,char *source); /* function prototypes */
- Handle str2h (char *str);
-
- pascal void EntryPoint (XCmdPtr paramPtr)
- {
- HParamBlockRec block; /* File manager parameter Block */
- char loadingZone[1024]; /* space for 31 volumes and their buds */
- char iobuffer[34]; /* space for volume names */
- short index = 1; /* the index into the volume list */
- OSErr err = noErr; /* a place for my funky errors */
-
- loadingZone[0] = 0; /* clear out that thar string */
-
- block.fileParam.ioNamePtr = &iobuffer[0]; /* give the ioNamePtr some iobuffer */
- do {
- block.volumeParam.ioVolIndex = index; /* set the index */
-
- err = PBHGetVInfo (&block,false); /* get the info on vol # index */
- if (err)
- break;
-
- SCopy (strlen(&loadingZone[0]),&loadingZone[0], /* slam the name into the buffer */
- p2cstr(block.fileParam.ioNamePtr));
- SCopy (strlen(&loadingZone[0]),&loadingZone[0], /* add the formating stuff */
- "\n\0");
-
- ++index;
-
- } while (true);
-
- paramPtr->returnValue = str2h (&loadingZone[0]); /* set up the return values */
-
- return; /* Get the flock out of here */
- }
-
- /*
- ** SCopy(pos,dest,source)
- ** Does the 'ol full service string copy thing. Pos specifies the starting position in the
- ** destination. Whopppe.
- */
- void SCopy (pos,dest,source)
- unsigned short pos;
- char dest[],source[];
- {
- unsigned short i=0; /* normal index declaration */
-
- while (dest[i+pos] = source[i]) i++; /* standard string copy routine */
- }
-
- /*
- ** str2h (str)
- ** copies a string into a handle and returns it
- */
- Handle str2h (str)
- char *str;
- {
- Handle new;
-
- new = NewHandle ((long) strlen(str) + 1);
- strcpy ((char *) (*new), str);
-
- return (new);
- }